package com.sc.service.goods;

import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.sc.dal.mapper.goods.GoodsBrandMapper;
import com.sc.dal.model.goods.GoodsBrand;

/**
 * 商品品牌服务实现
 * @author maoyongbin
 * @日期 Mar 13, 2017 4:55:21 PM
 */
@Service
public class GoodsBrandService {
	@Autowired
	private GoodsBrandMapper goodsBrandMapper;
	
	/**
	 * 根据id，查找商品品牌
	 * @param id
	 * @return GoodsBrand
	 */
	public GoodsBrand selectByPrimaryKey(Integer id){
		GoodsBrand goodsBrand = this.goodsBrandMapper.selectByPrimaryKey(id);
		
		return goodsBrand;
	}

	/**
     * 查找所有商品品牌
     * @param paramMap
     * @return List<GoodsBrand>
     */
    public List<GoodsBrand> selectList(Map<String, Object> paramMap){
    	List<GoodsBrand> goodsBrandList = this.goodsBrandMapper.selectList(paramMap);
    	
    	return goodsBrandList;
    }
    
    /**
	  * <h2>取得商品品牌实体对象数据</h2>
	  * @Title: getGoodsBrandData
	  * @Description: 取得商品品牌实体对象数据
	  * @param @param GoodsBrand
	  * @return Map<String,Object>    返回类型
	 */
	public List<Object> getGoodsBrandData(List<GoodsBrand> goodsBrandList){
		List<Object> goodsBrandMapList = new ArrayList<Object>();
		for(GoodsBrand goodsBrand : goodsBrandList){
			Map<String,Object> dataMap = new LinkedHashMap<String,Object>();
			dataMap.put("id",goodsBrand.getId());
			dataMap.put("code",goodsBrand.getCode());
			dataMap.put("name",goodsBrand.getName());
			dataMap.put("position",goodsBrand.getPosition());
			
			goodsBrandMapList.add(dataMap);
		}
		
		
		return goodsBrandMapList;
	}
	
	/**
	 * 新增商品品牌
	 * @param goodsBrand
	 * @return int
	 */
	public int insert(GoodsBrand goodsBrand){
		int resultInt = this.goodsBrandMapper.insert(goodsBrand);
		
		return resultInt;
	}
	
	/**
	 * 更新商品品牌
	 * @param goodsBrand
	 * @return int
	 */
	public int update(GoodsBrand goodsBrand){
		int resultInt = this.goodsBrandMapper.updateByPrimaryKey(goodsBrand);
		
		return resultInt;
	}
}
